package jinyilw.swing.visuals.Rcomp;

import jinyilw.swing.ComponentTools;
import jinyilw.swing.rlaf.theme.RThemeColor;
import jinyilw.swing.rlaf.ui.RComboBoxUI;

import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import java.awt.Composite;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.Vector;

public class RComboBox<E> extends JComboBox<E>
{
	private static final long serialVersionUID = -4235525716993461205L;

	public RComboBox()
	{
		super();
	}

	public RComboBox(ComboBoxModel<E> aModel)
	{
		super(aModel);
	}

	public RComboBox(E[] items)
	{
		super(items);
	}

	public RComboBox(Vector<E> items)
	{
		super(items);
	}

	@Override
	public void updateUI()
	{
		setUI(new RRComboBoxUI());
		// super.updateUI();
	}

	static class RRComboBoxUI extends RComboBoxUI
	{
		@Override
		public void update(Graphics g, JComponent c)
		{
			Composite composite = ComponentTools
					.applyEnableAlpha((Graphics2D) g, c, 1f, 0.3f);
			arrowButton.setForeground(RThemeColor.colorSet.textColor);
			if (editor != null)
				editor.setForeground(RThemeColor.colorSet.textColor);
			paint(g, c);
			if (composite != null)
				((Graphics2D) g).setComposite(composite);
		}
	}
}
